import BScroll from 'better-scroll';
import { computed } from 'vue';
import {
    pullDownRefresh, pullUpLoad, downStatus, upStatus
} from './config';

const downEnum = {
    '1': '下拉即可刷新...',
    '2': '释放即可刷新...',
    '3': '加载中...',
    '4': '刷新完成'
};
const upEnum = {
    '1': '',
    '2': '加载中...',
    '3': '加载完成'
};

const downMsg = computed(() => downEnum[downStatus.value]);
const upMsg = computed(() => upEnum[upStatus.value]);

export default {
    initBs(ele) {
        const bs = new BScroll(ele, {
            pullUpLoad,
            pullDownRefresh,
            'click':true
        });
        return bs;
    },
    get 'downStatus'() {
        return downStatus;
    },
    get 'downMsg'() {
        return downMsg;
    },
    get 'upStatus'() {
        return upStatus;
    },
    get 'upMsg'() {
        return upMsg;
    },
    get 'pullDownRefresh'() {
        return pullDownRefresh;
    },
    get 'pullUpLoad'() {
        return pullUpLoad;
    }
};
